package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.api.ApiService;
import com.lwj.liwanjia.bean.SeckillMoreBean;
import com.lwj.liwanjia.impl.SeckillMoreView;
import com.lwj.liwanjia.model.SeckillMoreModel;
import com.lwj.liwanjia.utils.RetrofitHelper;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/27.
 */

public class SeckillMorePresenter {
    private SeckillMoreView seckillMoreView;
    private SeckillMoreModel seckillMoreModel;

    public SeckillMorePresenter(SeckillMoreView seckillMoreView) {
        this.seckillMoreView = seckillMoreView;
        seckillMoreModel = new SeckillMoreModel();
    }

    public void getSeckillMore( int page, String time) {
        if (seckillMoreView != null) {
            seckillMoreModel.getSeckillMore( page, time, new Subscriber<SeckillMoreBean>() {
                @Override
                public void onCompleted() {
                    seckillMoreView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    seckillMoreView.showError((Exception) e);
                    seckillMoreView.hideProgress();
                }

                @Override
                public void onNext(SeckillMoreBean seckillMoreBean) {
                    seckillMoreView.getSeckillMore(seckillMoreBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    seckillMoreView.showProgress();
                }
            });
        }
    }
}
